<?php

/*
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
 * 
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * I18NHelper.
 *
 * @package    symfony
 * @subpackage helper
 * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
 * @version    SVN: $Id: I18NHelper.php 29597 2010-05-24 06:00:11Z fabien $
 */

function ___($text, $args = array())
{
  if (sfConfig::get('sf_i18n'))
  {
    return ToolbaseI18N::getInstance()->___($text, $args);
  }
  else
  {
    if (empty($args))
    {
      $args = array();
    }

    // replace object with strings
    foreach ($args as $key => $value)
    {
      if (is_object($value) && method_exists($value, '__toString'))
      {
        $args[$key] = $value->__toString();
      }
    }

    return strtr($text, $args);
  }
}

function i18n( $key /* ... */ )
{

  return call_user_func_array( array( ToolbaseI18N::getInstance(), 'i18n' ), func_get_args() );
  
}
